﻿@using System.Collections.Generic
@using System.Linq
@using Microsoft.Gateway.Utils.Update
@{
    ViewBag.Title = "Home Page";
}
<div class="hero-unit">
    <h2>Service Gateway</h2>
    <div id="update-banner" class="alert alert-dismissable hidden">
        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
        An update is available for this Management Console application.
        <span class="pull-right"><a href="@Url.Action("Update")" class="alert-link">Update Now</a></span>
    </div>
    <p>The Service Gateway is an Application Proxy service that should be required for ALL internet facing web sites and applications. It provides <strong>Protection</strong>, <strong>Monitoring</strong> and <strong>Lifecycle Management</strong> which are essential qualities to all highly available web properties in a super-easy configuration and management package.</p>
    <p>The high level qualities are realized by the following set of features:</p>
    <h4>Protection</h4>
    <ul>
        <li>Authentication and Authorization using <em>Azure Active Directory</em></li>
        <li>(Coming soon) Denial of Service (DoS) and Distributed Denial of Service (DDoS) detection and protection</li>
    </ul>
    <h4>Monitoring</h4>
    <ul>
        <li>Web logs for all traffic through the Gateway are persisted to <em>Microsoft Azure Storage</em></li>
@if (Configuration.AzureEnvironment != Microsoft.Gateway.Utils.AzureEnvironments.AzureChinaCloud)
{ 
        <li><em>Microsoft Azure HDInsight</em> can be scheduled to process web logs and provide application insights</li>
        <li>Common analytics reports included</li>
        <li>Ability to connect Excel/BI Tools to run ad-hoc application analytics queries</li>
}
    </ul>
    <h4>Lifecycle Management</h4>
    <ul>
        <li>A/B Testing. Run new versions of components in production environment with controlled percentage of traffic directed to new versions. Ramp distribution up or down.</li>
        <li>Compose multiple application roles to create single, cohesive application. Increase agility by decomposing monolithic applications without making user experience fragmented.</li>
        <li>Distribute traffic to multiple resources based on a variety of criteria by creating 'Flights'. Enables customer or user routing.</li>
    </ul>
    <h2>Getting Started</h2>
    <p>The following diagram depicts the high level architecture of an application using the Service Gateway:</p>
    <img src="~/Content/Images/architecture.PNG" width="100%" />
</div>

<div class="row">
    <h3>Step 1: Configure Roles </h3>
    <p>

    </p>
    <p><a href="~/Role" class="btn btn-primary btn-large">Configure Roles &raquo;</a></p>
    <h3>Step 2: Configure Security </h3>
    <p>

    </p>
    <p><a href="~/Security" class="btn btn-primary btn-large">Configure Security &raquo;</a></p>
    <h3>Step 3: Deploy Gateway </h3>
    <p>

    </p>
    <p><a href="~/Deployment" class="btn btn-primary btn-large">Deploy Gateway &raquo;</a></p>

@if (Configuration.AzureEnvironment != Microsoft.Gateway.Utils.AzureEnvironments.AzureChinaCloud)
{
    <h3>Step 4: Configure Analytics </h3>
    <p>

    </p>
    <p><a href="~/Analytics" class="btn btn-primary btn-large">Configure Analytics &raquo;</a></p>
}
</div>

@section Scripts {
    <script type="text/javascript">

        $(document).ready(function () {
            var checkUpdate = @(Configuration.NoUpdateCheck ? "false" : "true");
            if (checkUpdate)
            {
                $.ajax({
                    type: "GET",
                    url: '@Url.Action("IsConsoleUpdateAvailable")',
                    error: function (xhr, status, error) {
                    },
                    success: function (response) {
                        if (response.AvailableUpdate) {
                            var alertClass = 'alert-info';
                            switch (response.HighestServerify) {
                                case 'Critical':
                                    alertClass = 'alert-danger';
                                    break;

                                case 'Important':
                                    alertClass = 'alert-warning'
                                    break;

                                default:
                                    alertClass = 'alert-info';
                                    break;
                            }
                            $("#update-banner").addClass(alertClass);
                            $("#update-banner").removeClass('hidden');
                        }
                    }
                });
            }
        });

    </script>
}
